<html>
<head><meta charset="utf-8"><title>proper way to add custom attributes? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html">proper way to add custom attributes?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201596749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/proper%20way%20to%20add%20custom%20attributes%3F/near/201596749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html#201596749">(Jun 22 2020 at 12:01)</a>:</h4>
<p>I just saw that plugins are deprecated, so what's the proper way to register a custom attribute with rust? proc macros?</p>



<a name="201596879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/proper%20way%20to%20add%20custom%20attributes%3F/near/201596879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html#201596879">(Jun 22 2020 at 12:02)</a>:</h4>
<p>also can i define a non-outer attribute? I'd like to attach them to loops for example</p>



<a name="201597181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/proper%20way%20to%20add%20custom%20attributes%3F/near/201597181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html#201597181">(Jun 22 2020 at 12:06)</a>:</h4>
<p>Yep proc-macro are the thing now if I'm not mistaken</p>



<a name="201597224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/proper%20way%20to%20add%20custom%20attributes%3F/near/201597224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html#201597224">(Jun 22 2020 at 12:07)</a>:</h4>
<p>but proc-macros aren't actually attributes in the compiler :/ I'd like to register a custom attribute and read it back in MIR</p>



<a name="201597330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/proper%20way%20to%20add%20custom%20attributes%3F/near/201597330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html#201597330">(Jun 22 2020 at 12:08)</a>:</h4>
<p>i don't actually want to transform any user code, I just want to have metadata which gets passed along the compilation pipeline :/</p>



<a name="201597657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/proper%20way%20to%20add%20custom%20attributes%3F/near/201597657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html#201597657">(Jun 22 2020 at 12:12)</a>:</h4>
<p>No idea then, sorry !</p>



<a name="201597664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/proper%20way%20to%20add%20custom%20attributes%3F/near/201597664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html#201597664">(Jun 22 2020 at 12:12)</a>:</h4>
<p>i guess i'll need to build up a hashmap in a global mutable state var</p>



<a name="201597680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/proper%20way%20to%20add%20custom%20attributes%3F/near/201597680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html#201597680">(Jun 22 2020 at 12:12)</a>:</h4>
<p><span class="user-mention" data-user-id="312719">@Xavier Denis</span> <a href="https://github.com/rust-lang/rust/issues/66079">https://github.com/rust-lang/rust/issues/66079</a> (<code>#![register_tool]</code>) and <a href="https://github.com/rust-lang/rust/issues/66080">https://github.com/rust-lang/rust/issues/66080</a> (<code>#![register_attribute]</code>)</p>



<a name="201597707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/proper%20way%20to%20add%20custom%20attributes%3F/near/201597707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/proper.20way.20to.20add.20custom.20attributes.3F.html#201597707">(Jun 22 2020 at 12:13)</a>:</h4>
<p>ohhhhh this looks exactly like what I need <span class="user-mention" data-user-id="133247">@bjorn3</span> !</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>